package com.ytjj.qmyx.admin.service;

import com.alibaba.fastjson.JSONObject;
import com.alipay.api.response.AlipayDataDataserviceBillDownloadurlQueryResponse;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.ytjj.common.api.CommonPage;
import com.ytjj.common.api.CommonResult;
import com.ytjj.qmyx.admin.model.BillExportRecord;
import com.ytjj.qmyx.admin.model.dto.SonOrderDto;
import com.ytjj.qmyx.admin.model.excel.OrdersExceptionExcel;
import com.ytjj.qmyx.admin.model.request.*;
import com.ytjj.qmyx.admin.model.request.exportInterface.NotifyOrderInfoRequest;
import com.ytjj.qmyx.admin.model.response.*;
import com.ytjj.qmyx.admin.model.response.order.MainOrderResponse;
import com.ytjj.qmyx.admin.model.response.order.OrderDetailResponse;
import com.ytjj.qmyx.admin.model.vo.SonOrderVO;
import com.ytjj.qmyx.mall.model.*;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.util.List;
import java.util.Map;

/**
 * 订单服务
 *
 *
 * @version 1.0
 *
 */
public interface OrdersService {

    /**
     * 获取订单列表
     *
     * @param request
     * @return
     */
    CommonPage getOrdersList(OrdersRequest request);

    /**
     * 写订单小记
     *
     * @param content
     */
    void writeRecord(String content, Integer orderId);

    /**
     * 获取订单明细列表
     *
     * @param request
     * @return
     */
    CommonPage getOrdersInfoList(OrdersInfoRequest request);

    /**
     * 批量更新订单快递
     *
     * @param list
     */
    List<String> batchUpdateOrders(List<OrdersExpressRequest> list);

    /**
     * 导出excel
     *
     * @param request
     * @return
     */
    List<OrdersInfoResponse> exportOrdersExcel(OrdersInfoRequest request);

    /**
     * 改变导出订单的 "状态" 跟 "时间"
     *
     * @param orderCheackRequest
     * @return
     */
    int updateOrderCheack(OrderCheackRequest orderCheackRequest);

    /**
     * 处理快递信息
     *
     * @param jsonObject
     */
//    void handleExpressInfo(JSONObject jsonObject);

    /**
     * 订单退款
     *
     * @param orderId
     */
    void refundOrders(Integer orderId, String desc);

    /**
     * 处理退款
     *
     * @param notifyMap
     */
    void handleRefund(Map<String, String> notifyMap);

    void updateCourier(CourierInfosRequest courierInfosRequest);

    void editOrdersStatus(Integer orderId, String orderStatus);


    List<Orders> getAllOrder();

    List<OrdersInfo> getAllOrdersInfoByOrderId(Integer orderId);

    Integer updateStatusByOrderId(String ordersinfoStatus, Integer orderId);

    OrderDetailResponse getOrderDetail(Integer orderId);



    void updateOrderInfo(OrderAddressRequest orderAddressRequest);


    List<ExpressDic> getExpressDicList();

    List<TwoOrdersResponse> getTwoOrdersList(OrdersRequest request);

    List<TwoOrdersResponse> batchExportTwoOrderList(OrdersRequest request);

    void batchInsertOrders(List<TwoOrderRequest> collect);

    int InsertOrders(List<NewImportOrderRequest> collect);

    boolean fillOrderExpress(Integer orderId, String expressCompanyNo, String expressNo,Integer orderInfoId);

    boolean insertExpress(@Param("orderId") Integer orderId, @Param("expressCompanyNo") String expressCompanyNo, @Param("expressNo") String expressNo, @Param("orderInfoId")Integer orderInfoId);

    boolean fillOrder(@Param("expressCompanyNo") String expressCompanyNo, @Param("expressNo") String expressNo, @Param("express") String express,@Param("orderInfoId") Integer orderInfoId);

    /**
     * 获取订单明细列表缩减版
     */
    CommonPage getOrdersInfoListCurtail(OrdersInfoRequest request);

    /**
     * 获取订单列表缩减版
     *
     */
    CommonPage getOrdersListCurtail(OrdersRequest request);

    /**
     * 获取订单详情缩减版
     */
    OrderDetailResponse getOrderDetailCurtail(Integer orderId);

    MainOrderResponse getOrderDetailByOrderNo(String orderNo);

    Integer updateSmallNote(String orderNo, String smallNote);

    List<SonOrderVO> selectOrderInfoAll(SonOrderDto sonOrderDto);

    MainOrderResponse getChildOrderDetail(String orderNo,String childOrderNo,Integer orderInfoId);

    CommonResult updateOrderInfoStatus(Integer orderInfoId);

    CommonResult updateAddress(ReceiveAddressRequest request);
    /**
     * @Description 更新订单表格信息
     *
     *
     *
     * @Version 1.0
     **/
    void updateOrdersExpressInfo(List<NewImportOrderRequest> ordersExpressRequestList);

    boolean insertOrderRemark(String childOrderNo,String serviceRemark, Integer orderInfoId);

    List<OrdersExportResponse> findAllOrderInfo(OrdersInfoRequest ordersInfoRequest);

    String exportOrderInfo(OrdersInfoRequest ordersInfoRequest)throws Exception;

    int batchUpdateChildOrderStatus(NotifyOrderInfoRequest request);

    void updateOrderStatus(NotifyOrderInfoRequest request);

    String updateOrderExpressInfo(String childOrderNo, String expressCompanyNo, String expressNo);

    CommonResult updateWxAppOrdersStatus();

    CommonResult updateAliPayAppOrdersStatus();

    int updateOrderExpressBySaleSystem(String childOrderNo, String expressCompanyCode, String expressNo);

    void handleRefundV2(Orders orders, OrdersRefund ordersRefund, OrdersInfo ordersInfo, OrdersPay ordersPay,Integer orderId, String desc);

    /**
     * Adapay 退款回调
     * @param request
     * @return void
     */
    Integer adapayCallBack(HttpServletRequest request);
    /**
     *
     */
    OrdersInfo queryByChildOrderNo(String childOrderNo);

    /**
     * 下载excle
     * @param fileName
     * @param response
     */
    void downloadExcel(String fileName, HttpServletResponse response);

    void downloadNewExcel(Integer id, HttpServletResponse response);


    /**
     * 校验补单
     * @param childOrderNo 子订单号
     * @param type 页面来源 1-同步到退货标识 2-补单标识
     */
    CommonResult reissueLogCheck(String childOrderNo,Integer type);

    /**
     * 导出异常订单
     * @param response
     * @param exceptionOrdersRequest
     * @return void
     */
    void exportExceptionOrders(HttpServletResponse response,ExceptionOrdersRequest exceptionOrdersRequest);


    /**
     * 导入excel异常订单,批量处理
     * @return
     */
    CommonResult<List<ImportExcelFailResponse>> batchInsertNote(MultipartFile file);

    /**
     * 异常订单-批量归类
     * @return
     */
    CommonResult batchDealExceptionOrders(Integer[] ids,Integer type);

    /**
     * 异常订单-批量不再显示
     * @return
     */
    CommonResult<List<ImportExcelFailResponse>> showExceptionOrders(ExceptionOrdersRequest exceptionOrdersRequest);


    CommonPage getExportOrderInfoRecordList(QueryOrderRecordRequest queryOrderRecordRequest);

    /**
     * 申请下载微信 资金账单
     */
    String createWxBill(PayBillRequest request);

    /**
     * 下载支付宝业务明细账单
     */
    String createAlipayBill(PayBillRequest request);


    /**
     * 导出账单
     */
    CommonResult exportFundBill(PayBillRequest request);

    /**
     * 获取支付宝账单地址
     */
    AlipayDataDataserviceBillDownloadurlQueryResponse getAlipayBillDownload(String dateTime,String billType,String childId) throws Exception;

    /**
     * 获取支付宝下载地址详情
     */
    AlipayDataDataserviceBillDownloadurlQueryResponse alipayFunds(String dateTime,String billType);

    /**
     * 支付账单下载列表
     */
    CommonPage<PayBillResponse> getBillListByPage(PayBillRequest request);

    /**
     * 从列表选择文件下载
     */
    void downloadBill(HttpServletResponse response,Integer id);

    /**
     * 从列表选择文件下载
     */
    Map<String,Object> getAllAccount();

    boolean checkIsLimitRole();
}


